import React from 'react';

import {
  View, StyleSheet, Text, Image,
  TouchableOpacity,
} from 'react-native';

const tip = isError => (isError ? '网络异常，点击刷新' : '暂无数据，点击刷新');
const IconImage = require('../../assets/images/search-fail.png');

export default ({ isError, onRefresh }) => (
  <View style={styles.container}>
    <TouchableOpacity style={styles.touchView} onPress={onRefresh}>
      <Image style={styles.image} source={isError ? require('../../assets/images/fail.png') : require('../../assets/images/search-fail.png')} resizeMode="stretch" />
      <Text style={styles.tip}>{ tip(isError) }</Text>
    </TouchableOpacity>
  </View>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  touchView: {
    justifyContent: 'center',
    alignItems: 'center',
  },
  tip: {
    fontSize: 15,
    color: 'white',
  },
  image: {
    marginBottom: 10,
    width: 100,
    height: 130,
  },
});
